/**
 * 
 */
package com.sidom.movieIndexer.factory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.sidom.movieIndexer.domain.Movie;
import com.sidom.movieIndexer.domain.file.MovieFile;
import com.sidom.movieIndexer.domain.file.MovieFileCleanedFileNameComparator;
import com.sidom.movieIndexer.domain.google.GoogleSearchResultImdbUrlComparator;

/**
 * Factory class for creating {@link List} of {@link Movie} objects.
 * 
 * @author Siebe
 */
public class MoviesFactory {
	public enum TestMovies {
		EMPTY_MOVIES,
		NULL_MOVIES,
		
		SINGLE_MOVIE_PERFECT_MATCH,
		SINGLE_MOVIE_MATCH,
		SINGLE_MOVIE_NO_MATCH,
		
		MULTIPLE_MOVIE_PERFECT_MATCH,
		MULTIPLE_MOVIE_MATCH,
		MULTIPLE_MOVIE_NO_MATCH,
		MULTIPLE_MOVIE_MIXED,
		MULTIPLE_MOVIE_UNCLEANED,
		
		ALL_AVI_MOVIES,
		ALL_AVI_MOVIES_WITHOUT_DUPLICATE_CLEANED_UP_FILE_NAMES,
		ALL_AVI_MOVIES_WITHOUT_DUPLICATE_IMDB_URLS,
		ALL_AVI_MOVIES_WITH_IMDB_URLS,
		
		ALL_AVI_MP4_MOVIES,
		ALL_AVI_MP4_MOVIES_WITHOUT_DUPLICATE_CLEANED_UP_FILE_NAMES,
		ALL_AVI_MP4_MOVIES_WITHOUT_DUPLICATE_IMDB_URLS;
	}
	
	/**
	 * Factory method for creating a {@link List} of test {@link Movie}s with only {@link MovieFile} information filled in.
	 * 
	 * @param testMovies The kind of {@link List} of {@link Movie}s to create: See {@link TestMovies}.
	 * @return A {@link List} of {@link Movie}s.
	 */
	public static List<Movie> createMoviesWithMovieFileInformation(TestMovies testMovies){
		List<Movie> movieList = createMovies(testMovies);
		for (Movie movie : movieList) {
			movie.setGoogleSearchResult(null);
			movie.setImdbResult(null);
		}
		return movieList;
	}
	
	/**
	 * Factory method for creating a {@link List} of test {@link Movie}s
	 * 
	 * @param testMovies The kind of {@link List} of {@link Movie}s to create: See {@link TestMovies}.
	 * @return A {@link List} of {@link Movie}s.
	 */
	public static List<Movie> createMovies(TestMovies testMovies){
		List<Movie> movies = new ArrayList<Movie>();
		switch (testMovies) {
			case NULL_MOVIES:
				return null;	
			case EMPTY_MOVIES:
				break;
			case MULTIPLE_MOVIE_NO_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_ITALIAN_JOB));
			case SINGLE_MOVIE_NO_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.NO_MOVIE_WITH_THIS_NAME));
				break;
			case MULTIPLE_MOVIE_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
			case SINGLE_MOVIE_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOX_OFFICE));
				break;
			case MULTIPLE_MOVIE_PERFECT_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD1));
			case SINGLE_MOVIE_PERFECT_MATCH:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				break;
			case MULTIPLE_MOVIE_MIXED:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.NO_MOVIE_WITH_THIS_NAME));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				break;
			case MULTIPLE_MOVIE_UNCLEANED:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.GONE_IN_60_SECONDS));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_ITALIAN_JOB));
				break;
			case ALL_AVI_MP4_MOVIES:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.GONE_IN_60_SECONDS));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.TRANSPORTER));
			case ALL_AVI_MOVIES:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOURNE_IDENTITY_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOURNE_IDENTITY_CD2));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD2));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD2));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MATRIX));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.NO_MOVIE_WITH_THIS_NAME));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOX_OFFICE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_ITALIAN_JOB));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MTRX));
				break;
			case ALL_AVI_MP4_MOVIES_WITHOUT_DUPLICATE_CLEANED_UP_FILE_NAMES:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.GONE_IN_60_SECONDS));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.TRANSPORTER));
			case ALL_AVI_MOVIES_WITHOUT_DUPLICATE_CLEANED_UP_FILE_NAMES:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOURNE_IDENTITY_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MATRIX));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.NO_MOVIE_WITH_THIS_NAME));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOX_OFFICE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_ITALIAN_JOB));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MTRX));
				Collections.sort(movies, new MovieFileCleanedFileNameComparator());
				break;
			case ALL_AVI_MP4_MOVIES_WITHOUT_DUPLICATE_IMDB_URLS:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.GONE_IN_60_SECONDS));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.TRANSPORTER));
			case ALL_AVI_MOVIES_WITHOUT_DUPLICATE_IMDB_URLS:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOURNE_IDENTITY_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MATRIX));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.NO_MOVIE_WITH_THIS_NAME));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOX_OFFICE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_ITALIAN_JOB));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
				Collections.sort(movies, new GoogleSearchResultImdbUrlComparator());
				break;
			case ALL_AVI_MOVIES_WITH_IMDB_URLS:
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOURNE_IDENTITY_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.EQUILIBRIUM_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.SWORDFISH_CD1));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.THE_MATRIX));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.BOX_OFFICE));
				movies.add(MovieFactory.createMovie(MovieFactory.TestMovie.YOUTUBE));
				Collections.sort(movies, new GoogleSearchResultImdbUrlComparator());
				break;
			default:
				break;
		}
		return movies;
	}
}
